package com.wxjfh.servlet;

import com.wxjfh.Utils.DataUtils;
import com.wxjfh.bean.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 获取学生集合并输出到querystudent.jsp
 */

@WebServlet("/querystudent")
public class QueryStudentServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //获取学生集合
        List<Student> stuList = DataUtils.queryStu();

        //学生集合放入request域，转发querystudent.jsp
        request.setAttribute("stuList", stuList);
        request.getRequestDispatcher("querystudent.jsp").forward(request, response);

    }
}
